package com.me.study.designPatterns.Observer;

import java.util.Observable;

/**
 * 观察者模式: 主人是被观察者
 *
 * @author ME
 * @date 2019/12/20
 */
public class MasterPerson extends Observable {

    public String name;

    public MasterPerson(String name) {
        this.name = name;
    }

    public void feed(String foodName) {
        System.out.printf("主人[%s]开始喂食了: %s\n\n", name, foodName);
        // 设置变化标记, 并且通知观察者
        setChanged();
        notifyObservers(foodName);
    }

}
